package com.zues.thread.lock.readwrite;

import com.zues.thread.util.ThreadUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName Demo1
 * @Description TODO
 * @Author zeus
 * @Date 3/25/2025 2:54 下午
 * @Version 1.0
 **/
@Slf4j(topic = "c.Demo1")
public class Demo1 {

    public static void main(String[] args) {

        DataContainer container = new DataContainer();
        //读写互斥，读读共享，写写互斥
        new Thread(() -> {
            container.read();
        }, "t1").start();

        ThreadUtil.sleep(1);
        new Thread(() -> {
            container.write();
        }, "t2").start();
    }

}
